<extend name="_Layout/main"/>

<block name="breadcrumb">
    <div class="container">
        <ul class="breadcrumb">
            <li><i class="icon-location-arrow"></i></li>
            <li><a href="__ROOT__/">首页</a></li>
            <li><a href="{:U('')}">{$meta_title}</a></li>
        </ul>
    </div>
</block>

<block name="main">
    <div class="container">
        <div class="row">
            <div class="col-xs-12 col-sm-3">
                <div class="thumbnail">
                    <img class="img-responsive" src="{$user_info.avatar|get_cover='avatar'}">
                </div>
            </div>
            <div class="col-xs-12 col-md-9">
                <div>
                    <header>
                        <h1>{$user_info.username}</h1>
                        <dl class="dl-horizontal">
                            <dt class="time">年龄：</dt><dd>{$user_info.age}岁</dd>
                            <dt class="time">生日：</dt><dd>{$user_info.birthday|time_format='Y-m-d'}</dd>
                            <dt class="time">最后登录：</dt><dd class="time">{$user_info.last_login_time|friendly_date}</dd>
                        </dl>
                        <div class="alert alert-warning">签名：{$user_info.summary}</div>
                    </header>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#comment" data-toggle="tab">留言</a></li>
                </ul>
                <div class="blank"></div>
                <div class="tab-content">
                    <div class="tab-pane fade in active" id="comment">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">{$user_info.comment} 条留言</h3>
                            </div>
                            <div class="panel-body">
                                <corethink:comment_list name="vo" table="$__CURRENT_TABLE_ID__" data_id="$user_info['id']">
                                    <div class="media border-bottom padding-bottom">
                                        <div class="media-left">
                                            <a href="{:U('User/home/uid/'.$vo['uid'])}" class="avatar">
                                                <img src="{$vo.avatar|get_cover='avatar'}" style="width:40px;height:40px;">
                                            </a>
                                        </div>
                                        <div class="media-body">
                                            <div class="pull-right">
                                                <span class="text-muted small">{$vo.ctime}</span> &nbsp;
                                                <strong class="text-muted small">#{$i}</strong>
                                            </div>
                                            <span class="author">
                                                <a href="#"><strong>{$vo.username}</strong></a>
                                                <notempty name="vo.pid">
                                                    <span class="reply">
                                                        <span class="text-muted small"> 回复 </span>
                                                        <a href="#">{$vo.parent_comment_username}</a>
                                                    </span>
                                                </notempty>
                                            </span>
                                            <div class="text">{$vo.content}</div>
                                            <div class="pictures">
                                                <foreach name="vo.pictures" item="img">
                                                    <a href="#"><img src="{$img|get_cover}" style="width:50px;height:50px;margin:5px 5px 5px 0px;border:1px solid #eee;"></a>
                                                </foreach>
                                            </div>
                                            <div class="small">
                                                <a href="javascript:void(0);" class="reply-action" comment_id="{$vo.id}" username="{$vo.username}">回复</a>
                                            </div>
                                        </div>
                                    </div>
                                </corethink:comment_list>
                            </div>
                        </div>
                        <php>if(C('TOGGLE_USER_COMMENT')):</php>
                            <div class="comment margin-bottom">
                                <notempty name="__USER__">
                                    <form action="{:U('PublicComment/add')}" method="post" class="form comment-form">
                                        <div class="form-group">
                                            <textarea name="content" class="form-control new-comment-text" rows="3" placeholder="留言是一种态度..."></textarea>
                                        </div>
                                        <div class="form-group">
                                            <input type="hidden" name="pid" value="0">
                                            <input type="hidden" name="table" value="{$__CURRENT_TABLE_ID__}">
                                            <input type="hidden" name="data_id" value="{$user_info.id}">
                                            <table style="display:inline-block">
                                                <tr>
                                                    <td>
                                                        <div id="preview_comment_picture"></div>
                                                    </td>
                                                    <td>
                                                        <input type="hidden" name="pictures">
                                                        <div id="upload_comment_picture" title="上传图片"></div>
                                                    </td>
                                                </tr>
                                            </table>
                                            <style type="text/css">
                                                /* 多图上传样式 */
                                                .img-box{
                                                    position:relative;vertical-align: top;
                                                }
                                                .img-box img{
                                                    width:30px;height:30px;margin-right:8px;
                                                }
                                                .img-box i{
                                                    color:red;position:absolute;top:-8px;right:2px;background:#fff;border-radius:20px;
                                                }
                                            </style>
                                            <script type="text/javascript">
                                                $(function(){
                                                    $('#upload_comment_picture').Huploadify({
                                                        uploader:'{:U("PublicUpload/upload")}',
                                                        fileTypeExts:'*.gif;*.jpg;*.jpeg;*.png;*.bmp',
                                                        fileSizeLimit:{:C('UPLOAD_IMAGE_SIZE')}*1024,
                                                        buttonText:'<span class="fa fa-plus"></span>',
                                                        onUploadComplete:function(file, data){
                                                            var data = $.parseJSON(data);
                                                            var input = $('input[name="pictures"]');
                                                            var new_img = '<span class="img-box"><img class="img" src="' + data.url + '"><i class="fa fa-times-circle"></i></span>';
                                                            $('#preview_comment_picture').append(new_img);
                                                            if(input.val()){
                                                                input.val(input.val() + ',' + data.id);
                                                            }else{
                                                                input.val(data.id);
                                                            }
                                                        }
                                                    });
                                                });
                                            </script>
                                            <a id="submit" type="submit" class="btn btn-primary ajax-post pull-right hidden-xs" target-form="comment-form"><i class="fa fa-comment-o"></i> 发表留言</a>
                                            <a id="submit" type="submit" class="btn btn-primary btn-block ajax-post margin-top visible-xs" target-form="comment-form"><i class="fa fa-comment-o"></i> 发表留言</a>
                                        </div>
                                    </form>
                                <else />
                                    <div>
                                        <a class="btn btn-success" href="{:U('User/register')}">注 册</a>
                                        <a class="btn btn-primary" data-toggle="modal" data-target="#login-modal">登 录</a>
                                    </div>
                                </notempty>
                                <script type="text/javascript">
                                    $(function(){
                                        $('.reply-action').click(function(){
                                            $('input[name=pid]').val($(this).attr('comment_id'));
                                            $('.new-comment-text').focus().attr('placeholder', '回复'+$(this).attr('username'));
                                        });
                                    });
                                </script>
                            </div>
                        <php>endif;</php>
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
